package offer;

/**
 * @Author SSK
 * @Date Created in 21:07 2019/8/7
 * @Description 对称的二叉树
 * @Version 1.0
 */
public class T59 {
    public class TreeNode {
        int val = 0;
        TreeNode left = null;
        TreeNode right = null;

        public TreeNode(int val) {
            this.val = val;

        }

    }
    boolean isSymmetrical(TreeNode pRoot)
    {
        if (pRoot==null) {
            return true;
        }
        return isSymmetrical(pRoot.left,pRoot.right);
    }
    public boolean isSymmetrical(TreeNode left, TreeNode right) {
        if (left==null) {
            return right==null;
        }
        if (right==null) {
            return false;
        }
        if (left.val!=right.val) {
            return false;
        }
        return isSymmetrical(left.left,right.right)&&isSymmetrical(left.right,right.left);

    }
}
